package com.ts.api.common.constant.channel;

import java.util.HashMap;
import java.util.Map;

/**
 * 注册字段枚举
 * 必须和数据库一致
 */
public enum ChannelRegisterFieldEnum {

    USER_NAME("姓名", "userName"),
    PHONE("手机号", "phone"),
    AREA_CODE("地区编码", "areaCode"),
    BANK_CARD("银行卡", "bankCard"),
    IDCARD("身份证", "idcard");

    private static final Map<String, ChannelRegisterFieldEnum> MAP = initMap();

    /** 字段名称 */
    private final String fieldName;
    /**  映射名称 */
    private final String mappingName;

    private ChannelRegisterFieldEnum(String fieldName, String mappingName) {
        this.fieldName = fieldName;
        this.mappingName = mappingName;
    }

    public String getFieldName() {
        return fieldName;
    }

    public String getMappingName() {
        return mappingName;
    }

    private static Map<String, ChannelRegisterFieldEnum> initMap() {
        Map<String, ChannelRegisterFieldEnum> map = new HashMap<>();
        map.put("姓名", ChannelRegisterFieldEnum.USER_NAME);
        map.put("手机号", ChannelRegisterFieldEnum.PHONE);
        map.put("地区编码", ChannelRegisterFieldEnum.AREA_CODE);
        map.put("银行卡", ChannelRegisterFieldEnum.BANK_CARD);
        map.put("身份证", ChannelRegisterFieldEnum.IDCARD);
        return map;
    }

    /**
     * 根据名称获取枚举
     *
     * @param name
     * @return
     */
    public static ChannelRegisterFieldEnum get(String name) {
        return MAP.get(name);
    }

}
